package cn.itsource.org.domain;

import cn.itsource.basic.Domain.BaseDomain;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.*;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
import java.util.ArrayList;
import java.util.List;

/**
 * @Author CTL
 * @Description
 * @date Created in 2023-05-16 13:46
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@Table(name = "t_department")
public class Department extends BaseDomain {
    //部门id


    @Size(min = 3, max = 6,message = "部门编号请输入3到6位数之间的字符串")
    //部门编号
    private String sn;
    //部门名称
    @NotBlank(message = "部门名称不能为空")
    private String name;
    //部门状态
    private Integer state;
    //部门管理员，关联employee的id

    private Long managerId;
    //上级部门
    private Long parentId;


    //部门路径
    private String dirPath;

    @Transient
    private String managerName;

    @Transient
    private String parentName;

    @Transient
    @JsonInclude(JsonInclude.Include.NON_EMPTY) //如果当前属性为空的集合，就转为null
    private List<Department> children=new ArrayList<Department>();

    //级联关系
    @Transient
    private Long[] parentIds;
}
